home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0107_Ask for insertion of diskette.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  1.3 KB  |  79 lines

  1. {$g+,n-,e-,d-,q-,r-,s-,t-,v-,x-}
  2. uses crt,dos;
  3.  
  4. function diskettedrives:integer; assembler;
  5. asm
  6.   xor ax,ax
  7.   xor bx,bx
  8.   xor cx,cx
  9.   xor dx,dx
  10.   int 011h
  11.   cmp ax,00001h
  12.   je @@exit2
  13.   @@exit2:
  14.     xor ax,ax
  15.   @@exit:
  16.   shl ax,8
  17.   shl ax,14
  18.   inc ax
  19. end;
  20.  
  21. var
  22.   buf:array [1..512]of byte;
  23.   ch:char;
  24.  
  25. function ready(drivespec:char):boolean; {A,B,etc}
  26. var
  27.   result:word;
  28.   drive,number,logical:word;
  29. begin
  30.   ready:=true;
  31.   drive:=ord(upcase(drivespec))-65;
  32.   if(drive>diskettedrives)then exit;
  33.   number:=1;
  34.   logical:=1;
  35.   asm
  36.     push bp
  37.     push ds
  38.     xor ax,ax
  39.     mov result,ax
  40.     mov al,byte ptr drive
  41.     mov cx,number
  42.     mov dx,logical
  43.     mov bx,seg buf
  44.     mov ds,bx
  45.     mov bx,offset buf
  46.     int 25h
  47.     pop bx
  48.     pop ds
  49.     pop bp
  50.     jnb @@done
  51.     mov result,ax
  52.    @@done:
  53.   end;
  54.   ready:=(result=0);
  55. end;
  56.  
  57. function dodummy(const d:char):boolean;
  58. var f:file;
  59. begin
  60.   dodummy:=false;
  61.   assign(f,d+':\dummy');
  62.   {$i-} rewrite(f,1); {$i+}
  63.   if(ioresult<>0)then
  64.   begin
  65.     exit;
  66.   end;
  67.   {$i-} close(f); {$i+}
  68.   if(ioresult<>0)then exit;
  69.   {$i-} erase(f); {$i+}
  70.   if(ioresult<>0)then exit;
  71.   dodummy:=true;
  72. end;
  73.  
  74. begin
  75.   repeat
  76.     writeln('insert a unprotected disk in drive A: and press any key!');
  77.     ch:=readkey;
  78.   until(ready('a'))and(dodummy('a'));
  79. end.